package com.manyauthenticationway.server.manyauthenticationway.config.handle

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.data.redis.connection.RedisConnectionFactory
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore
import org.springframework.stereotype.Component

@Component
class RedisTokenStoreHandle {
    @Autowired
    private lateinit var redisConnectionFactory: RedisConnectionFactory
    @Value("\${app.redis-prefix}")
    private lateinit var redisPrefix: String

    fun tokenStore(): RedisTokenStore {
        return RedisTokenStore(redisConnectionFactory).apply { setPrefix("$redisPrefix:") }
    }
}